"""Definition of the houseinfo content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtinfocontent import xtinfocontentMessageFactory as _

from my315ok.xtinfocontent.interfaces import Ihouseinfo
from my315ok.xtinfocontent.config import PROJECTNAME

houseinfoSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atapi.StringField(
        'category',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.classinfocategory",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"info category"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'district',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"district"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'cell',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"house belongto cell"),
            description=_(u""),
        ),
    ),


    atapi.FixedPointField(
        'area',
        storage=atapi.AnnotationStorage(),
        widget=atapi.DecimalWidget(
            label=_(u"area(m*m)"),
            description=_(u""),
        ),
        required=True,
        validators=('isDecimal'),
    ),


    atapi.StringField(
        'roomstype',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.roomstype",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"rooms type"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'decoration',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.decorations",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"decoration status"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'types',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.types",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"house types"),
            description=_(u""),
        ),
    ),


    atapi.IntegerField(
        'height',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"building height"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'fnumber',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"floor number"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),


    atapi.StringField(
        'position',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"detail position"),
            description=_(u""),
        ),
    ),


    atapi.IntegerField(
        'price',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"refer price"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),


    atapi.DateTimeField(
        'infoeffective',
        storage=atapi.AnnotationStorage(),
        widget=atapi.CalendarWidget(
            label=_(u"information effective date"),
            description=_(u""),
        ),
        validators=('isValidDate'),
    ),


    atapi.StringField(
        'memo',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"information memo"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'name',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"contact name"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'mailaddress',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"mail address"),
            description=_(u""),
        ),
        validators=('isEmail'),
    ),


    atapi.StringField(
        'phone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"phone number"),
            description=_(u""),
        ),
    ),


    atapi.IntegerField(
        'qqnumber',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"QQ number"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

houseinfoSchema['title'].storage = atapi.AnnotationStorage()
houseinfoSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(houseinfoSchema, moveDiscussion=False)


class houseinfo(base.ATCTContent):
    """a information about house salling,letting etc."""
    implements(Ihouseinfo)

    meta_type = "houseinfo"
    schema = houseinfoSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    category = atapi.ATFieldProperty('category')

    district = atapi.ATFieldProperty('district')

    cell = atapi.ATFieldProperty('cell')

    area = atapi.ATFieldProperty('area')

    roomstype = atapi.ATFieldProperty('roomstype')

    decoration = atapi.ATFieldProperty('decoration')

    types = atapi.ATFieldProperty('types')

    height = atapi.ATFieldProperty('height')

    fnumber = atapi.ATFieldProperty('fnumber')

    position = atapi.ATFieldProperty('position')

    price = atapi.ATFieldProperty('price')

    infoeffective = atapi.ATFieldProperty('infoeffective')

    memo = atapi.ATFieldProperty('memo')

    name = atapi.ATFieldProperty('name')

    mailaddress = atapi.ATFieldProperty('mailaddress')

    phone = atapi.ATFieldProperty('phone')

    qqnumber = atapi.ATFieldProperty('qqnumber')


atapi.registerType(houseinfo, PROJECTNAME)
